const connection = require('../../app/database')

class AuthService {

  // 普通登录
  async login(sno, password) {
    const statement = `select id, sno, nickname, phone, avatar, auth, createAt, updateAt from user where sno = ? and password = ?`
    const result = await connection.execute(statement, [sno, password])
    return result[0]
  }

  // token登录
  async authLogin(id){
    const statement = `select id, sno, nickname, phone, avatar, auth, createAt, updateAt from user where id = ?`
    const result = await connection.execute(statement, [id])
    return result[0]
  }

}

module.exports = new AuthService()
